package com.itheima.map;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Demo03 {

    public static void main(String[] args) {
        Map<String ,String> map= new TreeMap<>();
        map.put("马蓉","宝强");
        map.put("马蓉","宋喆");
        map.put("小璐","乃亮");
        map.put("小璐","PGone");
        map.put("杨幂","凯威");
        map.put("某某某","凯威");
     //   String value = map.get("马蓉");
       // System.out.println(value);
        // 先获取到所有的键的集合   Set
        Set<String> strings = map.keySet();
        //遍历获取到的所有的键
        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()){
            String key = iterator.next();
            String value = map.get(key);
            System.out.println(key+"%%%%"+value);
        }
        for (String key : strings) {
            String value = map.get(key);
            System.out.println(key+"@@@"+value);
        }

        strings.forEach(s->{
            //根据键找值
            String value = map.get(s);
            System.out.println(s+"===="+value);
        });



    }
}
